﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ZX.HIS.Common;

namespace ZX.HIS.UI.Controllers
{
    public class DrugUsageController : Controller
    {
        //
        // GET: /DrugUsage/
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult UpateDrugage(int id)
        {
            ZX.HIS.Model.DrugUsage tt = new Model.DrugUsage();
            ZX.HIS.BLL.DrugUsage bll = new ZX.HIS.BLL.DrugUsage();
            List<ZX.HIS.Model.DrugUsage> tlist = bll.DrugUsageShow();
            tt = tlist.Where(p => p.DrugUsageId == id).FirstOrDefault();
            ViewData["tt"] = tt;
            return View("Index");
        }
        public ActionResult AddDrugUsage(ZX.HIS.Model.DrugUsage tt)
        {
            ZX.HIS.BLL.DrugUsage bll = new ZX.HIS.BLL.DrugUsage();
            if (bll.AddDrugUsage(tt)>0)
            {
                return Content("<script>alert('添加成功');location.href='/DrugUsage/Index';</script>");
            }
            else
            {
                return Content("<script>alert('添加失败')</script>");
            }
        }
        public ActionResult DrugUsageUpt(ZX.HIS.Model.DrugUsage tt)
        {
            ZX.HIS.BLL.DrugUsage bll = new ZX.HIS.BLL.DrugUsage();
            if (bll.UpdateDrugUsage(tt) > 0)
            {
                return Content("<script>alert('修改成功');location.href='/DrugUsage/Index'</script>");
            }
            else
            {
                return Content("<script>alert('修改失败')</script>");
            }
        }
        public JsonResult FnDrugUsageList(int PageIndex, int PageSize)
        {
            ZX.HIS.BLL.DrugUsage bll = new ZX.HIS.BLL.DrugUsage();
            PageClass<ZX.HIS.Model.DrugUsage> tt = bll.PageDrugUsageList(PageIndex, PageSize);
            return Json(tt);
        }
       


    }
}
